class Solution {
	public int numberOfWeakCharacters(int[][] properties) {
		Arrays.sort(properties, (a, d) -> a[0] == d[0] ? a[1] - d[1] : d[0] - a[0]);
		int ans = 0;
		int maxd = properties[0][1];
		for (int i = 1; i < properties.length; i++) {
			int curd = properties[i][1];
			if (curd < maxd) {
				ans += 1;
			}
			maxd = Math.max(maxd, curd);
		}
		return ans;
	}
}

